﻿using System;
using System.Windows;
using System.Collections.Generic;

namespace SBPweb.PROvibe.Shared.Actors
{
    
    public class AncestorTreeNode<TElement>
        where TElement : FrameworkElement
    {

        private TElement element;
        private AncestorTreeNode<TElement> parent;
        private List<AncestorTreeNode<TElement>> children;

        public AncestorTreeNode(TElement element)
        {
            this.element = element;
            TElement parentElement = element.Parent as TElement;
            if (parentElement != null)
            {
                parent = new AncestorTreeNode<TElement>(parentElement);
                parent.children.Add(this);
            }
            this.children = new List<AncestorTreeNode<TElement>>();
        }

        public TElement Element
        {
            get
            {
                return element;
            }
        }

        public AncestorTreeNode<TElement> Parent
        {
            get
            {
                return parent;
            }
        }

        public List<AncestorTreeNode<TElement>> Children
        {
            get
            {
                return children;
            }
        }

        public bool IsRootNode
        {
            get
            {
                return Parent == null;
            }
        }
    }

}